Python matplotlib.patches.Rectangle用法及代码示例 |
您所在的位置:网站首页 › matplotlib 矩形 › Python matplotlib.patches.Rectangle用法及代码示例 |
Matplotlib是Python中令人惊叹的可视化库,用于二维阵列图。 Matplotlib是一个基于NumPy数组的多平台数据可视化库,旨在与更广泛的SciPy堆栈配合使用。 matplotlib.patches.Rectangle的matplotlib.patches.Rectangle类别用于矩形贴图到左下角xy =(x,y)并具有指定的宽度,高度和旋转角度的图。 用法: class matplotlib.patches.Rectangle(xy, width, height, angle=0.0, **kwargs)
参数: xy:左下角开始绘制矩形 width:矩形的宽度 height:矩形的高度。 angle:矩形的旋转角度。下表列出了有效的kwarg; PROPERTY DESCRIPTION agg_filter 一个过滤器函数,它使用一个(m,n,3)浮点数组和一个dpi值来返回一个(m,n,3)数组 alpha 浮点数或无 animated bool 抗锯齿或抗锯齿 unknown capstyle {‘butt’,“回合”,‘projecting’} clip_box Bbox clip_on bool clip_path [(Path,Transform)|补丁|无] color rgba元组的颜色或顺序 contains callable edgecolor或ec或edgecolors 颜色或无或‘auto’ facecolor或fc或facecolors 颜色或无 figure figure fill bool gid str hatch {‘/’、‘\’、‘|’、‘-’、‘+’、‘x’、‘o’、‘O’、‘.’、‘*’} in_layout bool joinstyle {‘miter’,“回合”,‘bevel’} 线型或ls {“-”,“-”,“-。”,“:”,“,(偏移量,on-off-seq),...} 线宽或线宽或lw 浮点数或无 path_effects AbstractPathEffect picker 无或布尔或浮点数或可赎回 path_effects AbstractPathEffect picker float或callable [[Artist,Event],Tuple [bool,dict]] rasterized 布尔还是无 sketch_params (比例:浮点数,长度:浮点数,随机性:浮点数) snap 布尔还是无 transform matplotlib.transforms.Transform url str visible bool zorder float范例1: import numpy as np import matplotlib.pyplot as plt from matplotlib.patches import Rectangle # The image X = np.arange(16).reshape(4, 4) # highlight some feature in the # middle boxes. fig = plt.figure() ax = fig.add_subplot(111) ax.imshow(X, cmap = plt.cm.gray, interpolation ='nearest') ax.add_patch( Rectangle((0.5, 0.5), 2, 2, fc ='none', ec ='g', lw = 10) ) plt.show()输出:
输出:
|
今日新闻 |
推荐新闻 |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |